package com.egoo.ticket.server.service;

import com.alibaba.fastjson.JSONObject;
import com.egoo.ticket.server.pojo.dto.*;
import com.egoo.ticket.server.pojo.entity.WorkOrder;
import com.egoo.ticket.server.pojo.entity.WorkOrderFieldReflect;
import com.egoo.ticket.server.pojo.vo.InteractiveDataVo;
import com.egoo.ticket.server.utils.common.DbResponse;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;
import java.util.Map;

/**
 * TODO 工单处理
 * 
 * @author DEV050572
 *
 */
public interface WorkOrderService {
	/**
	 * TODO 新建工单
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:16
	 * @param workOrderDto 1
	 * @return: com.egoo.ews.service.utils.DBResponse
	 */
	DbResponse create(WorkOrderDto workOrderDto);

	/**
	 * TODO 获取满足条件的列表
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:16
	 * @param workOrderSelectInputDto 1
	 * @return: com.egoo.ews.service.utils.DBResponse
	 */
	DbResponse select(WorkOrderSelectInputDto workOrderSelectInputDto);
	/**
	 * TODO 获取工单列表
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:17
	 * @param workOrderSelectInputDto 1
	 * @return: com.egoo.ews.service.utils.DBResponse
	 */
	DbResponse getWorkOrderList(WorkOrderSelectInputDto workOrderSelectInputDto);
	/**
	 * TODO 获取关联工单列表
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:17
	 * @param workOrderDto
	 * @return: com.egoo.ews.service.utils.DBResponse
	 */
	DbResponse selectConcatWorkOrderList(WorkOrderDto workOrderDto);

	/**
	 * TODO 取消关联工单
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:17
	 * @param currentWorkOrderId 1
	 * @param concatWorkOrderId 2
	 * @return: com.egoo.ews.service.utils.DBResponse
	 */
	DbResponse cancleConcatWorkOrder(String currentWorkOrderId, String concatWorkOrderId);

	/**
	 * TODO 批量关闭
	 * @param workOrderList
	 * @param userId
	 * @return
	 */
	Integer closeBatch(List<WorkOrder> workOrderList, String userId);

	/**
	 * TODO 批量删除
	 * @param workOrderList
	 * @param userId
	 * @return
	 */
	Integer deleteBatch(List<WorkOrder> workOrderList, String userId);

	/**
	 * TODO 获取对应节点信息
	 * @param workOrderTypeId
	 * @param formTemplateId
	 * @return
	 */
	WorkOrderCreateNodeDto getCreateNode(Long workOrderTypeId, Integer formTemplateId);

	/**
	 * TODO 处理工单
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:17
	 * @param workOrderDto 1
	 * @return: com.egoo.ews.service.utils.DBResponse
	 */
	DbResponse processWorkOrder(WorkOrderDto workOrderDto);
	/**
	 * TODO 工单退回上一步
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:22
	 * @param jsonObject 1
	 * @return: com.egoo.ews.service.utils.DBResponse
	 */
	DbResponse workOrderBackToLastStep(JSONObject jsonObject);

	/**
	 * TODO 根据id获取工单信息
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:18
	 * @param workOrderId 1
	 * @return: com.egoo.ews.service.vo.WorkOrder
	 */
	WorkOrder selectById(String workOrderId);

	/**
	 * TODO 更新工单
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:18
	 * @param workOrder 1
	 * @return: java.lang.Integer
	 */
	Integer updateWorkOrder(WorkOrder workOrder);

	/**
	 * TODO 获取开启的流程名列表
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:19
	 * @param tenantId 1
	 * @return: java.util.List<com.egoo.ews.service.vo.InteractiveData>
	 */
	List<InteractiveDataVo> selectAllOpenWorkOrderTypeName(String tenantId);

	/**
	 * TODO 获取工单状态列表
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:20
	 * @param tenantId 1
	 * @return: java.util.List<com.egoo.ews.service.vo.InteractiveData>
	 */
	List<InteractiveDataVo> selectAllWorkOrderStatusName(String tenantId);

	/**
	 * TODO 获取满足条件的工单列表
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:20
	 * @param field 1
	 * @param sortTag 2
	 * @return: java.util.List<com.egoo.ews.service.vo.WorkOrder>
	 */
	List<WorkOrder> selectByfieldAndSortTag(String field, Integer sortTag);

	/**
	 * TODO 上传附件
	 * @author: victor_tang
	 * @createtime: 2020/4/6 22:13
	 * @param file 附件
	 * @param tenantId 3
	 * @return: com.egoo.ews.service.utils.DBResponse
	 */
	JSONObject uploadFile(MultipartFile file, String tenantId);

	/**
	 * TODO 获取节点id和名称列表
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:20
	 * @param workOrderTypeId 1
	 * @return: java.util.List<com.egoo.ews.service.dto.NodeIdAndName>
	 */
	List<NodeIdAndNameDto> getSelectableNodes(Long workOrderTypeId, Long nodeId);

	/**
	 * TODO 工单详细信息展示数据
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:20
	 * @param id 1
	 * @param userId 2
	 * @return: com.egoo.ews.service.dto.ProcessMessageOutputDto
	 */
	ProcessMessageOutputDto getProcessMessage(String id, String userId);

	/**
	 * TODO 更新当前处理人
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:20
	 * @param workOrderDto 1
	 * @return: com.egoo.ews.service.utils.DBResponse
	 */
	DbResponse updateCurrentHandler(WorkOrderDto workOrderDto);

	/**
	 * TODO 动态拼接sql
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:21
	 * @param workOrderSelectInputDto 1
	 * @return: java.lang.String
	 */
	String joinSqlContion(WorkOrderSelectInputDto workOrderSelectInputDto);

	/**
	 * TODO 外部创建工单
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:21
	 * @param jsonObject 1
	 * @param workOrderDto 2
	 * @param workOrderFieldReflects 3
	 * @return: com.egoo.ews.service.utils.DBResponse
	 */
	DbResponse externalCreate(JSONObject jsonObject, WorkOrderDto workOrderDto, List<WorkOrderFieldReflect> workOrderFieldReflects);

	/**
	 * TODO 工单领取
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:22
	 * @param jsonObject 1
	 * @return: com.egoo.ews.service.utils.DBResponse
	 */
	DbResponse workOrderRecieve(JSONObject jsonObject);

	/**
	 * TODO 获取合并工单列表
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:22
	 * @param workOrderDto
	 * @return: java.util.List<com.egoo.ews.service.vo.WorkOrder>
	 */
	DbResponse getCombineWorkOrderInfo(WorkOrderDto workOrderDto);

	/**
	 * TODO 工单关注和取消关注
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:22
	 * @param jsonObject 1
	 * @return: void
	 */
	void monitorAndCancelWorkOrder(JSONObject jsonObject);

	/**
	 * TODO 撤回工单
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:22
	 * @param jsonObject 1
	 * @return: com.egoo.ews.service.utils.DBResponse
	 */
	DbResponse withdrawWorkOrder(JSONObject jsonObject);
	/**
	 * TODO 修改客户唯一标识
	 * @author: victor_tang
	 * @createtime: 2020/3/27 20:22
	 * @param jsonObject 1
	 * @return: com.egoo.ews.service.utils.DBResponse
	 */
    DbResponse updateCustomIdentify(JSONObject jsonObject);
	/**
	 * TODO 根据sessionId获取工单信息
	 * @author: victor_tang
	 * @createtime: 2020/3/26 14:51
	 * @param sessionId 1
	 * @return: com.egoo.ews.service.utils.DBResponse
	 */
    DbResponse getworkOrderInfoBySessionId(String sessionId,String userId);

	/**
	 * TODO
	 * @param workOrderDto
	 * @return
	 */
	DbResponse externalFlowInto(WorkOrderDto workOrderDto);

    DbResponse getAllBaseBussinessField(String workOrderTypeId, String tenantId);

	DbResponse advancedFilterData(String workOrderFilterMenuId,String tenantId);

	DbResponse alterWorkOderStatus(Map<String, Object> map);

	/**
	 * @Author: Donny_dong
	 * @Description: 状态编码转换
	 * @Param:
	 * @return:
	 * @Date: 2020/11/25
	 */
	default int translateStatus(Integer status){
		switch (status){
			case 1:
				status= 5;
				break;
			case 2:
				status= 6;
				break;
			case 3:
				status= 7;
				break;
			case 4:
				status= 8;
				break;
			case 5:
				status= 9;
				break;
			default:
				break;
		}
		return status;
	}
}
